package cn.virens.util.poi.exception;

import org.apache.commons.lang3.StringUtils;

public class ExcelException extends Exception {

	private static final long serialVersionUID = -4695596792277438038L;

	private String detailMessage;

	public ExcelException(String message) {
		this(message, null);
	}

	public ExcelException(String message, Throwable cause) {
		this.setCause(cause);
		this.setMessage(message);
	}

	protected Throwable setCause(Throwable cause) {
		if (cause != null) {
			return super.initCause(cause);
		} else {
			return this;
		}
	}

	protected void setMessage(String message) {
		this.detailMessage = message;
	}

	@Override
	public String getMessage() {
		if (StringUtils.isEmpty(detailMessage)) {
			return super.getMessage();
		} else {
			return detailMessage;
		}
	}
}
